// JavaScript Document

$(document).ready(function () {
	
	$("#home").click(function() { 
		clickHome(this);
		myScroll.scrollToPage(0, 0);
	});
	$("#about").click(function() {
		clickorder(this);
		myScroll.scrollToPage(1, 0);
	});
	$("#contact").click(function() { 
		//$(window).scrollTop(0,0);
		clickmore(this);
		myScroll.scrollToPage(2, 0);
	});
});
function loadImages() {
    if (document.getElementById) { // DOM3 = IE5, NS6
        document.getElementById('hidepage').style.visibility = 'hidden';
    } else {
        if (document.layers) { // Netscape 4
            document.hidepage.visibility = 'hidden';
        } else { // IE 4
            document.all.hidepage.style.visibility = 'hidden';
        }
    }
}
function changMenu(){
	var menu=$('#navigation').find('a').eq(myScroll.currPageX);
	menuname=$(menu).attr('id');
	if("home"==menuname){
		clickHome(menu);
	}else if("about"==menuname){
		clickorder(menu);
	}else if("contact"==menuname){
		clickmore(menu);
	}else{
		clickHome(menu);
	}
	
}


function clickHome(menu){
	$(menu).addClass('selected').find("img").attr("src","images/nav/item1ns_pre.png");
	$(menu).parent().parent().find('#about, #portfolio, #contact').removeClass('selected');
	$(menu).parent().parent().find(".about").hide().find("img").attr("src","images/nav/item2ns.png");
	$(menu).parent().find("#about").find("img").attr("src","images/nav/item2ns.png");
	$(menu).parent().parent().find(".portfolio").hide().find("img").attr("src","images/nav/item3ns.png");
	$(menu).parent().find("#portfolio").find("img").attr("src","images/nav/item3ns.png");
	$(menu).parent().parent().find(".contact").hide().find("img").attr("src","images/nav/item4ns.png");
	$(menu).parent().find("#contact").find("img").attr("src","images/nav/item4ns.png");
	$(".title").html("我要洗衣");
	
}
function clickorder(menu){
	$(menu).addClass('selected').find("img").attr("src","images/nav/item2ns_pre.png");
	$(menu).parent().parent().find('#home, #portfolio, #contact').removeClass('selected');
	$(menu).parent().parent().find(".home").hide().find("img").attr("src","images/nav/item1ns.png");
	$(menu).parent().find("#home").find("img").attr("src","images/nav/item1ns.png");
	$(menu).parent().parent().find(".portfolio").hide().find("img").attr("src","images/nav/item3ns.png");
	$(menu).parent().find("#portfolio").find("img").attr("src","images/nav/item3ns.png");
	$(menu).parent().parent().find(".contact").hide().find("img").attr("src","images/nav/item4ns.png");
	$(menu).parent().find("#contact").find("img").attr("src","images/nav/item4ns.png");
	$(".title").html("订单查询");
	
}

function clickmore(menu){
	$(menu).addClass('selected').find("img").attr("src","images/nav/item4ns_pre.png");
	$(menu).parent().parent().find('#home, #about, #portfolio').removeClass('selected');
	$(menu).parent().parent().find(".home").hide().hide().find("img").attr("src","images/nav/item1ns.png");
	$(menu).parent().find("#home").find("img").attr("src","images/nav/item1ns.png");
	$(menu).parent().parent().find(".about").hide().find("img").attr("src","images/nav/item2ns.png");
	$(menu).parent().find("#about").find("img").attr("src","images/nav/item2ns.png");
	$(menu).parent().parent().find(".portfolio").hide().find("img").attr("src","images/nav/item3ns.png");
	$(menu).parent().find("#portfolio").find("img").attr("src","images/nav/item3ns.png");
	$(".title").html("更多功能");
}

function jian(moeny,obj){
	var number=$(obj).next().find('p').text()-0;
	if(number>0){
		$(obj).next().find('p').text(number-1);
		var cnumber=$("#cnumber").text()-0;
		var cprice=$("#cprice").text();
		if(cnumber>0){
			$("#cnumber").text(cnumber-1)-0;
		}
		if(cprice>0){
			$("#cprice").text(cprice-moeny);
		}
	}
	
}
function jia(moeny,obj){
	/*var id=$(obj).prev().attr('class');
	alert(id);*/
	var number=$(obj).prev().find('p').text()-0;
	$(obj).prev().find('p').text(number+1);
	var cnumber=$("#cnumber").text()-0;
	var cprice=$("#cprice").text()-0;
	$("#cnumber").text(cnumber+1);
	$("#cprice").text(cprice+moeny);
}
function more(obj){
	var h1=$(obj).parent().prev().height()-0;
	var h2=$(obj).parent().height()-0;
	$(obj).next().height(h1).css("margin-top",-h2).show();
}
function hiddenmore(obj){
	//alert("rrr");
	$(obj).parent().hide();
}

function choice(obj){
    var radioId = $(obj).attr('name');
    $('label').attr('class','lnotchecked') && $(obj).attr('class', 'lchecked');
    $('input[type="radio"]').removeAttr('checked') && $('#' + radioId).attr('checked', 'checked');	 
}

function choiceaddr(obj){
	$('.choiceimg').attr('src','../../images/person/no_choice.png');
	$('.addrbox').removeAttr("style");
	$('.addrbox').removeClass("addrboxCheck");
	$(obj).find("img").first().attr('src','../../images/person/choice.png');
	$(obj).css('background-color',' #7ecef4');
	$(obj).addClass("addrboxCheck");
}
function choiceMoreImage(obj){
	if(obj=='1'){
		$("#moreBtns").html("<div class='more_btns'>"+
				"<img  src='images/more/more_11.png' onclick='choiceMoreImage(1)'>"+
				"<img  src='images/more/more_02.png' onclick='choiceMoreImage(2)'>"+
			"</div>"+
			"<div class='more_btns'>"+
				"<img  src='images/more/more_03.png' onclick='choiceMoreImage(3)'>"+
				"<img  src='images/more/more_04.png' onclick='choiceMoreImage(4)'>"+
			"</div>");
	}else if(obj=='2'){
		$("#moreBtns").html("<div class='more_btns'>"+
				"<img  src='images/more/more_01.png' onclick='choiceMoreImage(1)'>"+
				"<img  src='images/more/more_12.png' onclick='choiceMoreImage(2)'>"+
			"</div>"+
			"<div class='more_btns'>"+
				"<img  src='images/more/more_03.png' onclick='choiceMoreImage(3)'>"+
				"<img  src='images/more/more_04.png' onclick='choiceMoreImage(4)'>"+
			"</div>");
	}else if(obj=='3'){
		$("#moreBtns").html("<div class='more_btns'>"+
				"<img  src='images/more/more_01.png' onclick='choiceMoreImage(1)'>"+
				"<img  src='images/more/more_02.png' onclick='choiceMoreImage(2)'>"+
			"</div>"+
			"<div class='more_btns'>"+
				"<img  src='images/more/more_13.png' onclick='choiceMoreImage(3)'>"+
				"<img  src='images/more/more_04.png' onclick='choiceMoreImage(4)'>"+
			"</div>");
	}else if(obj=='4'){
		$("#moreBtns").html("<div class='more_btns'>"+
				"<img  src='images/more/more_01.png' onclick='choiceMoreImage(1)'>"+
				"<img  src='images/more/more_02.png' onclick='choiceMoreImage(2)'>"+
			"</div>"+
			"<div class='more_btns'>"+
				"<img  src='images/more/more_03.png' onclick='choiceMoreImage(3)'>"+
				"<img  src='images/more/more_14.png' onclick='choiceMoreImage(4)'>"+
			"</div>");
	}
	$(".morePI").addClass("hide");
	$('#more'+obj).removeClass("hide");
}

//格式化时间
function formatDate(timestamp){
	var str = "";
	var date = new Date(timestamp);
	str = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()+":"+date.getSeconds();
	return str;
}

//检测手机号码格式
function validateMobileNum(mobileNum){
	var re = /^[1][34578]\d{9}$/;
	if(!re.test(mobileNum)){
		return false;
	}else{
		return true;
	}
}

//检测充值金额正整数
function validateMoney(Money){
	var re =/^[0-9]*[1-9][0-9]*$/;
	return re.test(Money);
}

//对Date的扩展，将 Date 转化为指定格式的String 
//月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符， 
//年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 
//例子： 
//(new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 
//(new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18 
Date.prototype.Format = function(fmt) 
	{ //author: meizz 
	var o = { 
	 "M+" : this.getMonth()+1,                 //月份 
	 "d+" : this.getDate(),                    //日 
	 "h+" : this.getHours(),                   //小时 
	 "m+" : this.getMinutes(),                 //分 
	 "s+" : this.getSeconds(),                 //秒 
	 "q+" : Math.floor((this.getMonth()+3)/3), //季度 
	 "S"  : this.getMilliseconds()             //毫秒 
	}; 
	if(/(y+)/.test(fmt)) 
	 fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
	for(var k in o) 
	 if(new RegExp("("+ k +")").test(fmt)) 
	fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length))); 
	return fmt; 
}; 














